<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="icon" href="https://fe-static.authing.cn/dist/favicon.png" />
    <title>Authing SSO</title>
  </head>

  <body>
    <noscript>
      <strong
        >We're sorry but sso doesn't work properly without JavaScript enabled.
        Please enable it to continue.</strong
      >
    </noscript>
    <div id="app"></div>
  </body>
  <script>
    window.onload = function resize() {
      // 防止移动端登录按钮被遮挡
      document.getElementsByClassName(
        "authing-login-form-wrapper"
      )[0].style.height = window.innerHeight + "px";
    };
    String.prototype.endsWith = function(suffix) {
      return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
    const getQueryString = function(name) {
      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
      var r = window.location.search.substr(1).match(reg);
      if (r != null) {
        return unescape(r[2]);
      } else {
        return null;
      }
    };
    let appId = getQueryString("app_id") || getQueryString("client_id");
    const guard = new Guard(undefined, {
      appId: appId,
      hideClose: true,
      isSSO: true,
      SSOHost: location.origin, // 开发模式下，会代理转发到 localhost:5556/authorize
      // SSOHost: 'https://sso.authing.cn',
      qrcodeScanning: {
        redirect: false
      },
      host: {
        user: "<%= htmlWebpackPlugin.options.API_ENDPOINT %>",
        oauth: "<%= htmlWebpackPlugin.options.API_ENDPOINT %>",
      },
      timeout: 30000,
      passwordEncPublicKey: "<%= htmlWebpackPlugin.options.PUBLIC_KEY %>",
    });
  </script>
</html>
